from enums.ResultEnum import StatusCode, MessageType

from flask import jsonify


class Response:
    def __init__(self):
        self.message = ""
        self.code = ""
        self.data = ""

    def success(self, data=None):
        if data:
            self.data = data
        self.code = StatusCode.SUCCESS.value
        self.message = MessageType.SUCCESS.value
        return jsonify(self.__dict__)

    def error(self):
        self.code = StatusCode.ERROR.value
        self.message = MessageType.ERROR.value
        return jsonify(self.__dict__)

    def errorMsg(self, msg):
        self.code = StatusCode.ERROR.value
        self.message = str(msg)
        return jsonify(self.__dict__)

    def waringMsg(self, err_msg):
        self.code = StatusCode.WARNING.value
        self.message = str(err_msg)
        return jsonify(self.__dict__)



